package genetischeralgorithmus;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Dominik
 */
import java.util.*;
import java.awt.*;

public class Population {

 Random rand1 = new Random();
 Entity[] entities;

/*
 * Erzeugt Startpopulation
 */
public void initialise(int Coding, int placesCount, int startPop){
    switch(Coding){
        case 1: // Real
            entities = new Entity[startPop];
            for (int i=0; i<startPop; i++){  //Aeussere Schleife bestimmt Anzahl an Start-Entitaeten

            //Fuellt eine Hilfsliste mit genau sovielen Elementen wie Ziele angegeben wurden.
            LinkedList<Integer> helpList = new LinkedList();
            for (int h = 1; h<=placesCount;h++){
                helpList.add(h);
             }
                Entity entity1 = new Entity(placesCount);
                for (int j=placesCount; j>0; j--){
                    int random = rand1.nextInt(j);
                    entity1.add(helpList.get(random));
                    helpList.remove(random);
                }

                entities[i] = entity1;
            }
          break;
    }

}

public Entity[] getEntities() {
    return entities;
}

public void setEntities(Entity[] entities) {
        this.entities = entities;
    }

public void clear(){
    entities = null;
}




}
